import type { SysDictionaryPageQo, SysDictionaryQo, SysDictionaryVo } from '#/system/dict/dict'
import { http } from '@/utils/request/index'

/**
 * 获取字典分页列表
 * @param params 查询参数
 * @returns 字典列表
 */
export function getDictPageListApi(params: SysDictionaryPageQo) {
  return http.request<PageResult<SysDictionaryVo>>('get', '/admin-api/system/sysDictionary/sysDictionaryPage', {
    params,
  })
}

/**
 * 获取字典详情
 * @param id 字典id
 * @returns 字典详情
 */
export function getDictDetailsApi(id?: string) {
  return http.request<SysDictionaryVo>('get', `/admin-api/system/sysDictionary/sysDictionaryDetails/${id}`)
}

/**
 * 新增字典
 * @param data 字典信息
 * @returns 字典id
 */
export function createDictApi(data: SysDictionaryQo) {
  return http.request<string>('post', '/admin-api/system/sysDictionary/sysDictionaryCreate', {
    data,
  })
}

/**
 * 修改字典
 * @param data 字典信息
 * @returns 字典id
 */
export function updateDictApi(data: SysDictionaryQo) {
  return http.request<string>('post', '/admin-api/system/sysDictionary/sysDictionaryUpdate', {
    data,
  })
}

/**
 * 删除字典
 * @param idList 字典id列表
 * @returns 字典id
 */
export function deleteDictApi(idList: string[]) {
  return http.request<string>('post', '/admin-api/system/sysDictionary/sysDictionaryRemove', {
    params: {
      idList: idList.join(','),
    },
  })
}

/**
 * 启用字典
 * @param idList 字典id列表
 * @returns 字典id
 */
export function enableDictApi(idList: string[]) {
  return http.request<string>('post', '/admin-api/system/sysDictionary/sysDictionaryEnable', {
    params: {
      idList: idList.join(','),
    },
  })
}

/**
 * 禁用字典
 * @param idList 字典id列表
 * @returns 字典id
 */
export function disableDictApi(idList: string[]) {
  return http.request<string>('post', '/admin-api/system/sysDictionary/sysDictionaryDisable', {
    params: {
      idList: idList.join(','),
    },
  })
}
